<?php


namespace Melon\Provider;


use Melon\Command\ServerStartCommand;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Melon\Foundation\Kernel;

class ConsoleProvider implements ServiceProviderInterface
{
    protected $commands = [
        ServerStartCommand::class,
    ];


    public function register(Container $pimple)
    {
        $pimple['console'] = function ($c) {
            return new Kernel($c);
        };

        $pimple->extend('console', function (Kernel $console) {
            foreach ($this->commands as $command) {
                $console->add(new $command);
            }
            return $console;
        });
    }
}